//
//  DeviceDetailFeature1Controller.m
//  DYLYJ
//
//  Created by JM on 15/11/11.
//  Copyright © 2015年 JM. All rights reserved.
//

#import "DeviceDetailFeature1Controller.h"
#import <AVFoundation/AVFoundation.h>
@interface DeviceDetailFeature1Controller ()
@property(nonatomic, strong) AVAudioPlayer *upDownStopPlayer;
@property(nonatomic, strong) AVAudioPlayer *othenrPlayer;
@end

@implementation DeviceDetailFeature1Controller

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //
    //1.音频文件的url路径
    NSURL *url=[[NSBundle mainBundle]URLForResource:@"上下停按钮音效.mp3" withExtension:Nil];
    
    //2.创建播放器（注意：一个AVAudioPlayer只能播放一个url）
    self.upDownStopPlayer=[[AVAudioPlayer alloc]initWithContentsOfURL:url error:Nil];
    //3.缓冲
    [self.upDownStopPlayer prepareToPlay];
    
    //1.音频文件的url路径
    NSURL *url2=[[NSBundle mainBundle]URLForResource:@"其他功能按钮音效.mp3" withExtension:Nil];
    
    //2.创建播放器（注意：一个AVAudioPlayer只能播放一个url）
    self.othenrPlayer=[[AVAudioPlayer alloc]initWithContentsOfURL:url2 error:Nil];
    //3.缓冲
    [self.othenrPlayer prepareToPlay];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (IBAction)clickUp:(UIButton *)sender {
    //    sender.enabled = !sender.enabled;
    [self.upDownStopPlayer play];
}
- (IBAction)clickStop:(UIButton *)sender {
    //    sender.enabled = YES;
     [self.upDownStopPlayer play];
}

- (IBAction)clickDown:(UIButton *)sender {
    //    sender.enabled = !sender.enabled;
     [self.upDownStopPlayer play];
}
- (IBAction)clickLight:(UIButton *)sender {
    sender.selected = !sender.selected;
     [self.othenrPlayer play];
}

- (IBAction)clickDry:(UIButton *)sender {
    sender.selected = !sender.selected;
      [self.othenrPlayer play];
}
- (IBAction)clickAirDry:(UIButton *)sender {
    sender.selected = !sender.selected;
      [self.othenrPlayer play];
}
- (IBAction)clickDisinfection:(UIButton *)sender {
    sender.selected = !sender.selected;
      [self.othenrPlayer play];
}
@end
